Skip to content

💚 Replace MinGW by clang - #10

Closed
Freed-Wu wants to merge 1 commit into
mainfrom
clang
Closed

💚 Replace MinGW by clang#10
Freed-Wu wants to merge 1 commit into
mainfrom
clang

Conversation

@Freed-Wu

@Freed-Wu Freed-Wu commented Jul 1, 2026

Copy link
Copy Markdown
Member

Fix #9

@Freed-Wu
Freed-Wu force-pushed the clang branch 6 times, most recently from 39b8366 to b2dfdb1 Compare July 1, 2026 08:27
@Freed-Wu

Freed-Wu commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

Even if we change gcc to clang, all program compiled by gcc to programs compiled by clang, it still output .dll.a not .lib.

$ 7z l pyrime-0.2.3-cp314-cp314-win_amd64.whl|rg api.cp
19:2026-07-01 08:37:28 .....       177152        70661  pyrime/api.cp314-win_amd64.pyd
20:2026-07-01 08:37:28 .....         1536          414  pyrime/api.cp314-win_amd64.dll.a

However, clang support to output .lib: Such as https://github.com/rime/librime/releases/download/1.17.0/rime-33e7814-Windows-clang-x64.7z

$ 7z l rime-33e7814-Windows-clang-x64.7z|rg dist/lib/rime
32:2026-06-05 19:42:26 ....A       301604               dist/lib/rime.lib
38:2026-06-05 19:42:26 ....A      5289472               dist/lib/rime.dll

I doubt clang has an option to decide output .lib or .dll.a .

@Freed-Wu Freed-Wu closed this Jul 1, 2026
@Freed-Wu
Freed-Wu deleted the clang branch July 1, 2026 08:43
@amorphobia

amorphobia commented Jul 6, 2026

Copy link
Copy Markdown
Member

I tried following piece of code in src/pyrime/__init__.py

if sys.platform == "win32":
    lib_dir = os.environ.get("LIBRIME_LIB_DIR")
    if lib_dir and os.path.isdir(lib_dir):
        os.add_dll_directory(lib_dir)

Just put official rime.dll for MSVC in path LIBRIME_LIB_DIR. Seemed work well. Not know the effect of .lib or .dll.a, but .dll seemed to be the key.

@amorphobia

Copy link
Copy Markdown
Member

The convention on Windows is to pack .dll with software releases (whl here). You are trying to do so, right?

@Freed-Wu

Freed-Wu commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

I know your meaning, if user doesn't install librime, it will not work because there is no any librime. In that situation, user must

  1. Install librime
  2. os.add_dll_directory() by themselves.

@amorphobia

amorphobia commented Jul 6, 2026

Copy link
Copy Markdown
Member

May I interpret your words in following manner:

It is the user (front-end)'s responsibility to invoke os.add_dll_directory() on Windows, but not pyrime's.

However, this requires the front-end to set directory before importing packages from pyrime. i.e., to write the script like

import os
os.add_dll_directory(some_dir_containing_rime_dll)

from pyrime.api import Traits
trait = Traits(...)

But in most cases, people are used to importing packages before other code. This will lead to exception of DLL not found. That's why I was adding the path setting in pyrime's init.

Just my two cents.

@Freed-Wu

Freed-Wu commented Jul 6, 2026

Copy link
Copy Markdown
Member Author
import os
os.add_dll_directory(some_dir_containing_rime_dll)

I think a better approach would be to set the PATH environment variable to include the directory containing the RIME DLLs before running the Python script. Refer 0fc2140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants